package com.yuanrui.practice.server.subject;


import com.yuanrui.practice.api.vo.PracticeSubjectOptionVO;
import com.yuanrui.practice.server.dao.SubjectMultipleDao;
import com.yuanrui.practice.server.enums.IsDeletedFlagEnum;
import com.yuanrui.practice.server.enums.SubjectInfoTypeEnum;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;

/**
 * 多选题目策略类
 */
@Component
public class MultipleTypeHandler implements SubjectTypeHandler {

    @Resource
    private SubjectMultipleDao subjectMultipleDao;
    @Override
    public SubjectInfoTypeEnum getSubjectType() {
        return SubjectInfoTypeEnum.MULTIPLE;
    }


    @Override
    public List<PracticeSubjectOptionVO> query(Long subjectId) {
        List<PracticeSubjectOptionVO> practiceSubjectOptionVOS = new LinkedList<>();
        subjectMultipleDao.selectBySubjectId(subjectId).forEach(multiplePO -> {
            PracticeSubjectOptionVO practiceSubjectOptionVO = new PracticeSubjectOptionVO();
            practiceSubjectOptionVO.setOptionContent(multiplePO.getOptionContent());
            practiceSubjectOptionVO.setIsCorrect(multiplePO.getIsCorrect());
            practiceSubjectOptionVO.setOptionType(multiplePO.getOptionType());
            practiceSubjectOptionVOS.add(practiceSubjectOptionVO);
        });
        return practiceSubjectOptionVOS;
    }
}
